import Stomp from 'stomp-client';

import activeMqConfig from '../config/activemq.js';
const destination = '/queue/someQueueName';

const client = new Stomp(activeMqConfig.host, activeMqConfig.port, activeMqConfig.user, activeMqConfig.pass);

let count = 0

client.connect((sessionId) => {
  client.subscribe(destination, (body, headers) => {
    console.log('This is the body of a message on the subscribed queue:', body);
  });

  let timer = setInterval(() => {
    count++;
    client.publish(destination, Math.random() + '');
    if(count > 10000) {
      clearInterval(timer);
    }
  })
});